//
//  ViewController.swift
//  soapp-docoment
//
//  Created by zhu xietong on 2022/12/28.
//

import UIKit
import Eelay
import soapp


class ViewController: ASListController {
    
    var sections:TP.section{
        get{
            return [
                [
                    [
                        "name":"flex","@click":_Click({ at in
                            let ctr = FlexDemo()
                            at.navigationController?.pushViewController(ctr, animated: true)
                        })
                    ],
                    [
                        "name":"update item","@click":_Click({ at in
                            at.navigationItem.leftBarButtonItem = UIBarButtonItem(systemItem: .action)
                        })
                    ]
                ]
                
            ]
        }
    }
    
    var selector:TP.selector{
        get{
            return ["<default>":Cell.self]
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        title = "my api"
        top_style = .red_deep
        tableNode.view.backgroundColor = ._tableBackground
        tableNode.view.backgroundView?.backgroundColor = ._tableBackground
        tableNode.load(sections: sections, selector: selector)
        tableNode.reloadData()
        // Do any additional setup after loading the view.
    }


    class Cell:JoCellNode{
        let name = ASTextNode2()
        override func addLayoutRules() {
        }
        
        override func mo_model_reload() {
            name.attributedText = mo["name"].ui.font14.color(color: ._foreground).astring
            backgroundColor = ._tableBackground
            name.backgroundColor = .red
        }
        
        override func specGetter() -> _Spec {
            return .inset([], [14], child: .stack(["h-10"], childs: [
                name|
            ]))
        }
    }
}


